home *** CD-ROM | disk | FTP | other *** search
/ Amiga CD-Sensation: Golden Games / Amiga CD-Sensation - Ausgabe 2 - Golden Games (1996)(GTI - Schatztruhe)(DE)[!].iso / Brain Activity / Conquest / Conquest2.mod < prev    next >
Text File  |  1992-12-20  |  49KB  |  1,829 lines

  1. IMPLEMENTATION MODULE Conquest2;
  2.  
  3.  
  4.  
  5. IMPORT
  6.   Conversions,
  7.   DosD,DosL,
  8.   MLL:MathLibLong,
  9.   RN:RandomNumber,
  10.   LongRealConversions,
  11.   String,
  12.   SYSTEM;
  13.  
  14.  
  15.  
  16. PROCEDURE PutStr(a: ARRAY OF CHAR);
  17.   VAR
  18.     tmp: LONGINT;
  19.   BEGIN
  20.     tmp:=DosL.Write(rawFile,SYSTEM.ADR(a),String.Length(a));
  21.   END PutStr;
  22.  
  23.  
  24.  
  25. PROCEDURE PutCh(c: CHAR);
  26.   VAR
  27.     tmp: LONGINT;
  28.   BEGIN
  29.     tmp:=DosL.Write(rawFile,SYSTEM.ADR(c),1);
  30.   END PutCh;
  31.  
  32.  
  33.  
  34. PROCEDURE PutInt(n,w: LONGINT);
  35.   VAR
  36.     str: Line;
  37.     err: BOOLEAN;
  38.   BEGIN
  39.     Conversions.ValToStr(n,FALSE,str,10,w," ",err);
  40.     IF NOT err THEN
  41.       PutStr(str);
  42.     END;
  43.   END PutInt;
  44.  
  45.  
  46.  
  47. PROCEDURE PutReal(r: LONGREAL; w,d: LONGINT);
  48.   VAR
  49.     str: Line;
  50.     err: BOOLEAN;
  51.   BEGIN
  52.     LongRealConversions.RealToStr(r,str,w,d,FALSE,err);
  53.     IF NOT err THEN
  54.       PutStr(str);
  55.     END;
  56.   END PutReal;
  57.  
  58.  
  59.  
  60. PROCEDURE SetCursorPos(col,row: IntType);
  61.   BEGIN
  62.     PutStr("\033["); PutInt(row,0);
  63.     PutCh(";"); PutInt(col,0); PutCh("H");
  64.     cursor.x:=col;
  65.     cursor.y:=row;
  66.   END SetCursorPos;
  67.  
  68.  
  69.  
  70. PROCEDURE CursorOff;
  71.   BEGIN
  72.     PutStr("\x9b\x30\x20\x70");     (* cursor off   *)
  73.   END CursorOff;
  74.  
  75.  
  76.  
  77. PROCEDURE CursorOn;
  78.   BEGIN
  79.     PutStr("\x9b\x20\x70");
  80.   END CursorOn;
  81.  
  82.  
  83.  
  84. PROCEDURE GetChar(VAR c: CHAR);
  85.   VAR
  86.     result: CHAR;
  87.     tmp: LONGINT;
  88.   BEGIN
  89.     CursorOn;
  90.     tmp:=DosL.Read(rawFile,SYSTEM.ADR(result),1);
  91.     CursorOff;
  92.     IF result="\r" THEN
  93.       result:="\n";
  94.     END;
  95.     IF result="\t" THEN
  96.       result:=" ";
  97.     END;
  98.     c:=result;
  99.     IF (c>="a") AND (c<="z") THEN
  100.       c:=CHAR((IntType(c)-IntType("a"))+IntType("A"));
  101.     END;
  102.     PutCh(c);
  103.     IF c="\b" THEN
  104.       PutStr("  \b\b");
  105.     END;
  106.   END GetChar;
  107.  
  108.  
  109.  
  110. PROCEDURE GetLine(VAR iline: Line; VAR ind: IntType; onech: BOOLEAN);
  111.   VAR
  112.     ch: CHAR;
  113.   BEGIN
  114.     ind:=1;
  115.     REPEAT
  116.       GetChar(ch);
  117.       IF ch="\b" THEN
  118.         (* backspace *)
  119.         IF ind>1 THEN
  120.           DEC(ind);
  121.           IF (ind#1) AND onech THEN
  122.             PutStr("\b \b");
  123.             DEC(ind);
  124.           END;
  125.           IF (ind#1) AND (NOT onech) THEN
  126.             PutCh(" ");
  127.             PutCh(ch);
  128.           END;
  129.         ELSE
  130.           PutCh(" ");
  131.         END;
  132.       ELSIF ch#"\n" THEN
  133.         iline[ind]:=ch;
  134.         INC(ind);
  135.         IF onech THEN
  136.           PutCh(" ");
  137.           iline[ind]:=" ";
  138.           INC(ind);
  139.         END;
  140.       END;
  141.     UNTIL (ind>=25) OR (ch="\n");
  142.     WHILE ind<80 DO
  143.       iline[ind]:=" ";
  144.       INC(ind);
  145.     END;
  146.     ind:=1;
  147.   END GetLine;
  148.  
  149.  
  150.  
  151. PROCEDURE min(x,y: IntType): IntType;
  152.   BEGIN
  153.     IF x<y THEN
  154.       RETURN x;
  155.     ELSE
  156.       RETURN y;
  157.     END;
  158.   END min;
  159.  
  160.  
  161.  
  162. PROCEDURE fmin(a,b: LONGREAL): LONGREAL;
  163.   BEGIN
  164.     IF a<b THEN
  165.       RETURN a;
  166.     ELSE
  167.       RETURN b;
  168.     END;
  169.   END fmin;
  170.  
  171.  
  172.  
  173. PROCEDURE ClearScreen;
  174.   BEGIN
  175.     SetCursorPos(1,1);
  176.     PutStr("\x9b\x4a"); (* erase to end of display *)
  177.     SetCursorPos(1,1);
  178.   END ClearScreen;
  179.  
  180.  
  181.  
  182. PROCEDURE PrintMap;
  183.   VAR
  184.     i1,i2: IntType;
  185.   BEGIN
  186.     ClearScreen();
  187.  
  188.     FOR i1:=bdsize TO 1 BY -1 DO
  189.       IF (i1=1) OR ((i1 MOD 5)=0) THEN
  190.         PutInt(i1,2); PutCh("|");
  191.       ELSE
  192.         PutStr("  |");
  193.       END;
  194.  
  195.       FOR i2:=1 TO bdsize DO
  196.         PutCh(CHAR(board[i2][i1].enemy));
  197.         PutCh(CHAR(board[i2][i1].star));
  198.         PutCh(CHAR(board[i2][i1].tf));
  199.       END;
  200.       PutStr("|\n");
  201.     END;
  202.  
  203.     PutStr("   ");
  204.  
  205.     FOR i1:=1 TO bdsize DO
  206.       PutStr("---");
  207.     END;
  208.  
  209.     PutStr("\n   ");
  210.  
  211.     FOR i1:=1 TO bdsize DO
  212.       IF (i1=1) OR ((i1 MOD 5)=0) THEN
  213.         PutInt(i1,2); PutCh(" ");
  214.       ELSE
  215.         PutStr("   ");
  216.       END;
  217.     END;
  218.     PutCh('\n');
  219.     SetCursorPos(32,18); PutStr("Turn: "); PutInt(turn,3);
  220.     SetCursorPos(32,19); PutStr("Production yr: "); PutInt(prodYear,1);
  221.     bottomField:=0;
  222.   END PrintMap;
  223.  
  224.  
  225.  
  226. PROCEDURE PrintResearch(field: CHAR);
  227.   BEGIN
  228.     CASE field OF
  229.       |"V": SetCursorPos(53,18);
  230.             PutStr("V:"); PutInt(vel[player],2);
  231.             IF vel[player]<maxVelocity THEN
  232.               PutStr(" res:"); PutInt(velocityResearch[player],5);
  233.               PutStr(" need:"); PutInt(velocityRequired[vel[player]+1],5);
  234.             ELSE
  235.               PutStr("                   ");
  236.             END;
  237.       |"R": SetCursorPos( 53,19);
  238.             PutStr("R:"); PutInt(curRange[player],2);
  239.             IF curRange[player]<maxRange THEN
  240.               PutStr(" res:"); PutInt(rangeResearch[player],5);
  241.               PutStr(" need:"); PutInt(rangeRequired[curRange[player]+1],5);
  242.             ELSE
  243.               PutStr("                   ");
  244.             END;
  245.       |"W": SetCursorPos(53,20);
  246.             PutStr("W:"); PutInt(weapons[player],2);
  247.             IF weapons[player]<maxWeapons THEN
  248.               PutStr(" res:"); PutInt(weaponResearch[player],5);
  249.               PutStr(" need:"); PutInt(weaponRequired[weapons[player]+1],5);
  250.             ELSE
  251.               PutStr("                   ");
  252.             END;
  253.       |ELSE
  254.     END;
  255.   END PrintResearch;
  256.  
  257.  
  258.  
  259. PROCEDURE ClearLeft;
  260.   VAR
  261.     i: INTEGER;
  262.   BEGIN
  263.     FOR i:=19 TO 24 DO
  264.       SetCursorPos(1,i);
  265.       PutStr(blankLine);
  266.     END;
  267.   END ClearLeft;
  268.  
  269.  
  270.  
  271. PROCEDURE GetToken(VAR line: Line; VAR index,value: IntType; VAR token: CHAR);
  272.   BEGIN
  273.     value:=0;
  274.     token:=" ";
  275.  
  276.     WHILE (line[index]=" ") AND (index<80) DO
  277.       INC(index);
  278.     END;
  279.  
  280.     IF index<80 THEN
  281.       IF (line[index]<"0") OR (line[index]>"9") THEN
  282.         value:=1;
  283.       ELSE
  284.         WHILE (line[index]>="0") AND (line[index]<="9") DO
  285.           value:=10*value+IntType(line[index])-IntType("0");
  286.           INC(index);
  287.         END;
  288.       END;
  289.       token:=line[index];
  290.       INC(index);
  291.     END;
  292.  
  293.     WHILE (line[index]#" ") AND (index<80) DO
  294.       INC(index);
  295.     END;
  296.  
  297.     WHILE (line[index]=" ") AND (index<80) DO
  298.       INC(index);
  299.     END;
  300.   END GetToken;
  301.  
  302.  
  303.  
  304. PROCEDURE ResearchSummary;
  305.   VAR
  306.     key: CHAR;
  307.     value: IntType;
  308.     ind: IntType;
  309.     iline: Line;
  310.   BEGIN
  311.     ClearLeft;
  312.     PrintResearch("R");
  313.     PrintResearch("V");
  314.     PrintResearch("W");
  315.   END ResearchSummary;
  316.  
  317.  
  318.  
  319. PROCEDURE NewResearch;
  320.   BEGIN
  321.     IF weapons[player]-weapons[ENEMY]>1 THEN
  322.       enemyResearch:="W";
  323.     ELSE
  324.       IF curRange[ENEMY]<6 THEN
  325.         enemyResearch:="R";
  326.       ELSIF vel[ENEMY]<3 THEN
  327.         enemyResearch:="V";
  328.       ELSE
  329.         CASE RN.RND(10) OF
  330.           |0..2: enemyResearch:="V";
  331.           |3..5: enemyResearch:="R";
  332.           |6..9: enemyResearch:="W";
  333.         END;
  334.       END;
  335.     END;
  336.   END NewResearch;
  337.  
  338.  
  339.  
  340. PROCEDURE DoResearch(team: Team; field: CHAR; amt: IntType);
  341.   BEGIN
  342.     CASE field OF
  343.       |"W": IF weapons[team]<maxWeapons THEN
  344.               weaponResearch[team]:=weaponResearch[team]+amt;
  345.               amt:=0;
  346.               IF weaponResearch[team]>=weaponRequired[weapons[team]+1] THEN
  347.                 amt:=weaponResearch[team]-weaponRequired[weapons[team]+1];
  348.                 INC(weapons[team]);
  349.                 IF team=ENEMY THEN
  350.                   NewResearch;
  351.                   field:=enemyResearch;
  352.                 END;
  353.                 weaponResearch[team]:=0;
  354.                 DoResearch(team,field,amt);
  355.               END;
  356.             END;
  357.       |"R": IF curRange[team]<maxRange THEN
  358.               rangeResearch[team]:=rangeResearch[team]+amt;
  359.               amt:=0;
  360.               IF rangeResearch[team]>=rangeRequired[curRange[team]+1] THEN
  361.                 amt:=rangeResearch[team]-rangeRequired[curRange[team]+1];
  362.                 INC(curRange[team]);
  363.                 IF team=ENEMY THEN
  364.                   NewResearch;
  365.                   field:=enemyResearch;
  366.                 END;
  367.                 rangeResearch[team]:=0;
  368.                 DoResearch(team,field,amt);
  369.               END;
  370.             END;
  371.       |"V": IF vel[team]<maxVelocity THEN
  372.               velocityResearch[team]:=velocityResearch[team]+amt;
  373.               amt:=0;
  374.               IF velocityResearch[team]>=velocityRequired[vel[team]+1] THEN
  375.                 amt:=velocityResearch[team]-velocityRequired[vel[team]+1];
  376.                 INC(vel[team]);
  377.                 IF team=ENEMY THEN
  378.                   NewResearch;
  379.                   field:=enemyResearch;
  380.                 END;
  381.                 velocityResearch[team]:=0;
  382.                 DoResearch(team,field,amt);
  383.               END;
  384.             END;
  385.       |ELSE PutStr("error in research field ");
  386.             PutCh(field);
  387.             PutCh("\n");
  388.     END;
  389.   END DoResearch;
  390.  
  391.  
  392.  
  393. PROCEDURE AnyWarShip(team: Team; starnum: IntType): BOOLEAN;
  394.   VAR
  395.     any: BOOLEAN;
  396.     tfNum: IntType;
  397.   BEGIN
  398.     any:=FALSE;
  399.     IF tfStars[starnum][team]>0 THEN
  400.       tfNum:=1;
  401.       WHILE (NOT any) AND (tfNum<27) DO
  402.         any:=(tf[team][tfNum].dest=starnum) AND
  403.              (tf[team][tfNum].eta=0) AND
  404.              ((tf[team][tfNum].c>0) OR (tf[team][tfNum].b>0));
  405.         INC(tfNum);
  406.       END;
  407.     END;
  408.     RETURN any;
  409.   END AnyWarShip;
  410.  
  411.  
  412.  
  413. PROCEDURE FindBestPlan(starnum: IntType; VAR size: IntType; VAR team: Team);
  414.   VAR
  415.     curPlanet: PlanetPtr;
  416.   BEGIN
  417.     team:=none;
  418.     size:=0;
  419.     curPlanet:=stars[starnum].firstPlanet;
  420.     WHILE curPlanet#NIL DO
  421.       IF curPlanet^.capacity>size THEN
  422.         size:=curPlanet^.capacity;
  423.         team:=curPlanet^.team;
  424.       END;
  425.       curPlanet:=curPlanet^.next;
  426.     END;
  427.   END FindBestPlan;
  428.  
  429.  
  430.  
  431. PROCEDURE CheckGameOver;
  432.   VAR
  433.     dead: ARRAY Team OF BOOLEAN;
  434.     quit: BOOLEAN;
  435.     total: Attribute;
  436.     transports: Attribute;
  437.     inhabs: Attribute;
  438.     team: Team;
  439.     tfnum: IntType;
  440.     starnum: IntType;
  441.     pplan: PlanetPtr;
  442.   BEGIN
  443.     quit:=gameOver;
  444.     FOR team:=ENEMY TO player DO
  445.       transports[team]:=0;
  446.       inhabs[team]:=0;
  447.       FOR tfnum:=1 TO 26 DO
  448.         IF tf[team][tfnum].dest#0 THEN
  449.           transports[team]:=transports[team]+tf[team][tfnum].t;
  450.         END;
  451.       END;
  452.     END;
  453.  
  454.     FOR starnum:=1 TO nstars DO
  455.       pplan:=stars[starnum].firstPlanet;
  456.       WHILE pplan#NIL DO
  457.         CASE pplan^.team OF
  458.           |player: inhabs[player]:=inhabs[player]+pplan^.iu;
  459.           |ENEMY:  inhabs[ENEMY] :=inhabs[ENEMY] +pplan^.iu;
  460.           |ELSE
  461.         END;
  462.         pplan:=pplan^.next;
  463.       END;
  464.     END;
  465.  
  466.     FOR team:=ENEMY TO player DO
  467.       total[team]:=inhabs[team]+(transports[team] DIV 2);
  468.       dead[team]:=(total[team]=0);
  469.     END;
  470.  
  471.     IF (NOT dead[player]) AND (NOT dead[ENEMY]) AND (turn>=40) THEN
  472.       dead[ENEMY]:=((total[player] DIV total[ENEMY])>=16);
  473.       dead[player]:=((total[ENEMY] DIV total[player])>=16);
  474.     END;
  475.     gameOver:=dead[player] OR dead[ENEMY] OR (turn>maxTurns) OR quit;
  476.  
  477.     IF gameOver THEN
  478.       ClearScreen();
  479.       PutStr("*** Game over ***\n\n");
  480.       PutStr("Player: Population in transports: ");
  481.       PutInt(transports[player],4);
  482.       PutStr("  IU's on colonies: ");
  483.       PutInt(inhabs[player],4);
  484.       PutStr("  TOTAL: ");
  485.       PutInt(total[player],4);
  486.       PutStr("\n\nEnemy:  Population in transports: ");
  487.       PutInt(transports[ENEMY],4);
  488.       PutStr("  IU's on colonies: ");
  489.       PutInt(inhabs[ENEMY],4);
  490.       PutStr("  TOTAL: ");
  491.       PutInt(total[ENEMY],4);
  492.       IF (total[ENEMY]>total[player]) THEN
  493.         PutStr("\n\n*** THE ENEMY HAS CONQUERED THE GALAXY ***\n");
  494.       ELSIF (total[player]>total[ENEMY]) THEN
  495.         PutStr("\n\n*** PLAYER WINS- YOU HAVE SAVED THE GALAXY! ***\n");
  496.       ELSE
  497.         PutStr("\n\n*** DRAWN ***\n");
  498.       END;
  499.     END;
  500.   END CheckGameOver;
  501.  
  502.  
  503.  
  504. PROCEDURE UpdateBoard(x,y: IntType; option: Option);
  505.   VAR
  506.     screenX,screenY: IntType;
  507.   BEGIN
  508.     screenX:=3*x+1;
  509.     screenY:=16-y;
  510.     CASE option OF
  511.       |left:  SetCursorPos(screenX,screenY);
  512.               PutCh(board[x][y].enemy);
  513.       |right: SetCursorPos(screenX+2,screenY);
  514.               PutCh(board[x][y].tf);
  515.       |both:  SetCursorPos(screenX, screenY);
  516.               PutCh(board[x][y].enemy);
  517.               PutCh(board[x][y].star);
  518.               PutCh(board[x][y].tf);
  519.     END;
  520.   END UpdateBoard;
  521.  
  522.  
  523.  
  524. PROCEDURE ZeroTF(tm: Team; tfNum: IntType);
  525.   VAR
  526.     x,y,i: IntType;
  527.   BEGIN
  528.     IF tf[tm][tfNum].dest#0 THEN
  529.       x:=tf[tm][tfNum].x;
  530.       y:=tf[tm][tfNum].y;
  531.       IF tf[tm][tfNum].s+tf[tm][tfNum].t+tf[tm][tfNum].c+tf[tm][tfNum].b=0 THEN
  532.         IF tf[tm][tfNum].eta=0 THEN
  533.           DEC(tfStars[tf[tm][tfNum].dest][tm]);
  534.         END;
  535.         tf[tm][tfNum].dest:=0;
  536.         IF tm=player THEN
  537.           board[x][y].tf:=" ";
  538.           FOR i:=1 TO 26 DO
  539.             IF (tf[player][i].dest#0) AND (tf[player][i].x=x) AND (tf[player][i].y=y) THEN
  540.               IF board[x][y].tf=" " THEN
  541.                 board[x][y].tf:=CHAR(i+IntType("a")-1);
  542.               ELSE
  543.                 board[x][y].tf:="*";
  544.               END;
  545.             END;
  546.           END;
  547.           UpdateBoard(x,y,right);
  548.         END;
  549.       END;
  550.     END;
  551.   END ZeroTF;
  552.  
  553.  
  554.  
  555. PROCEDURE ClearField;
  556.   VAR
  557.     newBottom,y: IntType;
  558.   BEGIN
  559.     newBottom:=cursor.y-1;
  560.     IF newBottom<bottomField THEN
  561.       FOR y:=newBottom+1 TO bottomField DO
  562.         SetCursorPos(50,y);
  563.         PutStr("\x9b\x4b"); (* erase to EOL *)
  564.       END;
  565.     END;
  566.     bottomField:=newBottom;
  567.   END ClearField;
  568.  
  569.  
  570.  
  571. PROCEDURE JOWDispTF(num: IntType; name: CHAR);
  572.   BEGIN
  573.     IF num#0 THEN
  574.       PutInt(num,2);
  575.       PutCh(name);
  576.     ELSE
  577.       PutStr("   ");
  578.     END;
  579.   END JOWDispTF;
  580.  
  581.  
  582.  
  583. PROCEDURE DisplayTF(taskf: TaskForce);
  584.   BEGIN
  585.     JOWDispTF(taskf.t,"t");
  586.     JOWDispTF(taskf.s,"s");
  587.     JOWDispTF(taskf.c,"c");
  588.     JOWDispTF(taskf.b,"b");
  589.   END DisplayTF;
  590.  
  591.  
  592.  
  593. PROCEDURE Pause;
  594.   VAR
  595.     dummy: CHAR;
  596.   BEGIN
  597.     SetCursorPos(1,18);
  598.     PutStr("Press any key to continue... ");
  599.     GetChar(dummy);
  600.   END Pause;
  601.  
  602.  
  603.  
  604. PROCEDURE PrintPlanet(p: PlanetPtr; see: BOOLEAN);
  605.   BEGIN
  606.     IF ((cursor.y>21) AND (cursor.x>=50)) OR (cursor.y>24) THEN
  607.       Pause;
  608.       ClearField();
  609.       SetCursorPos(50,1);
  610.     END;
  611.  
  612.     PutInt(p^.number,1); PutCh(":");
  613.     PutInt(p^.pSeeCapacity,3); PutStr("                         ");
  614.     SetCursorPos(cursor.x+6,cursor.y);
  615.     DEC(cursor.x,6);
  616.     IF p^.pSeeCapacity=0 THEN
  617.       PutStr(" Decimated");
  618.     ELSIF (p^.team=none) AND see THEN
  619.       PutStr(" No colony");
  620.     ELSIF p^.team=player THEN
  621.       PutCh("("); PutInt(p^.inhabitants,3);
  622.       PutCh("/"); PutInt(p^.iu,3); PutCh(")");
  623.       IF p^.conquered THEN
  624.         PutStr("Con ");
  625.       ELSE
  626.         PutStr("    ");
  627.       END;
  628.       IF p^.mb#0 THEN
  629.         PutInt(p^.mb,2); PutStr("mb ");
  630.       ELSE
  631.         PutStr("     ");
  632.       END;
  633.       IF p^.amb#0 THEN
  634.         PutInt(p^.amb,2); PutStr("amb");
  635.       END;
  636.     ELSIF (p^.team=ENEMY) AND see THEN
  637.       PutStr("(*ENEMY*)");
  638.       IF see AND p^.conquered THEN
  639.         PutStr("Con ");
  640.       ELSE
  641.         PutStr("    ");
  642.       END;
  643.       IF p^.underAttack THEN
  644.         IF p^.mb#0 THEN
  645.           PutInt(p^.mb,2); PutStr("mb ");
  646.         ELSE
  647.           PutStr("     ");
  648.         END;
  649.         IF p^.amb#0 THEN
  650.           PutInt(p^.amb,2); PutStr("amb");
  651.         END;
  652.       END;
  653.     END;
  654.     SetCursorPos(cursor.x,cursor.y+1);
  655.   END PrintPlanet;
  656.  
  657.  
  658.  
  659. PROCEDURE PrintStar(stnum: IntType);
  660.   VAR
  661.     see: BOOLEAN;
  662.     i,x,y: IntType;
  663.     p: PlanetPtr;
  664.   BEGIN
  665.     IF (stnum>0) AND (stnum<=nstars) THEN
  666.       IF cursor.y+4+tfStars[stnum][player]+tfStars[stnum][ENEMY]>19 THEN
  667.         ClearField();
  668.         Pause;
  669.         SetCursorPos(50,1);
  670.       END;
  671.       IF stars[stnum].visit[player] THEN
  672.         see:=FALSE;
  673.         PutStr("----- star "); PutCh(CHAR(stnum+IntType("A")-1));
  674.         PutStr(" -----            ");
  675.         SetCursorPos(50,cursor.y+1);
  676.         x:=stars[stnum].x; y:=stars[stnum].y;
  677.         IF tfStars[stnum][player]#0 THEN
  678.           see:=TRUE;
  679.           FOR i:=1 TO 26 DO
  680.             IF (tf[player][i].dest=stnum) AND (tf[player][i].eta=0) THEN
  681.               PutStr("TF"); PutCh(CHAR(i+IntType("a")-1));
  682.               PutStr("                           ");
  683.               SetCursorPos(54,cursor.y);
  684.               DisplayTF(tf[player][i]);
  685.               SetCursorPos(50,cursor.y+1);
  686.             END;
  687.           END;
  688.         END;
  689.  
  690.         IF NOT see THEN
  691.           see:=(colStars[stnum][player]#0);
  692.         END;
  693.  
  694.         IF see AND (tfStars[stnum][ENEMY]#0) THEN
  695.           i:=1;
  696.           WHILE (tf[ENEMY][i].eta#0) OR (tf[ENEMY][i].dest#stnum) DO
  697.             INC(i);
  698.           END;
  699.           PutStr("EN:                           ");
  700.           SetCursorPos(54,cursor.y);
  701.           DisplayTF(tf[ENEMY][i]);
  702.           SetCursorPos(50,cursor.y+1);
  703.         END;
  704.  
  705.         p:=stars[stnum].firstPlanet;
  706.         IF p=NIL THEN
  707.           PutStr("  no useable planets          ");
  708.           SetCursorPos(50,cursor.y+1);
  709.         ELSE
  710.           REPEAT
  711.             PutCh(" ");
  712.             PrintPlanet(p,see);
  713.             p:=p^.next;
  714.           UNTIL p=NIL;
  715.         END
  716.       END
  717.     END
  718.   END PrintStar;
  719.  
  720.  
  721.  
  722. PROCEDURE DisplayForces(ennum,plnum: IntType;
  723.                          VAR enodds,plodds: LONGREAL;
  724.                          VAR battle: BOOLEAN);
  725.   VAR
  726.     enForces,plForces: IntType;
  727.   BEGIN
  728.     enodds:=0.0;
  729.     plodds:=0.0;
  730.     ZeroTF(ENEMY,ennum);
  731.     ZeroTF(player,plnum);
  732.     battle:=TRUE;
  733.  
  734.     IF tf[ENEMY][ennum].dest#0 THEN
  735.       enForces:=weapons[ENEMY]*(tf[ENEMY][ennum].c*cruiserGuns+tf[ENEMY][ennum].b*battleShipGuns);
  736.     ELSE
  737.       battle:=FALSE;
  738.     END;
  739.  
  740.     IF tf[player][plnum].dest#0 THEN
  741.       plForces:=weapons[player]*(tf[player][plnum].c*cruiserGuns+tf[player][plnum].b*battleShipGuns);
  742.     ELSE
  743.       battle:=FALSE;
  744.     END;
  745.  
  746.     SetCursorPos(50,1);
  747.     IF tf[ENEMY][ennum].dest#0 THEN
  748.       PrintStar(tf[ENEMY][ennum].dest);
  749.     ELSIF tf[player][plnum].dest#0 THEN
  750.       PrintStar(tf[player][plnum].dest);
  751.     END;
  752.  
  753.     ClearField();
  754.  
  755.     IF (enForces=0) AND (plForces=0) THEN
  756.       battle:=FALSE;
  757.     END;
  758.  
  759.     IF battle THEN
  760.       enodds:=LONGREAL(plForces);
  761.       enodds:=enodds/LONGREAL(enForces+tf[ENEMY][ennum].t*transportDefend+
  762.                                        tf[ENEMY][ennum].s*scoutDefend);
  763.       enodds:=fmin(14.0,enodds);
  764.       enodds:=MLL.exp((MLL.log(0.8))*enodds);
  765.       plodds:=LONGREAL(enForces);
  766.       plodds:=plodds/LONGREAL(plForces+tf[player][plnum].t*transportDefend+
  767.                                        tf[player][plnum].s*scoutDefend);
  768.       plodds:=fmin(14.0,plodds);
  769.       plodds:=MLL.exp((MLL.log(0.8))*plodds);
  770.  
  771.       SetCursorPos(1,19);
  772.       PutStr("enemy "); PutInt(enForces,6);
  773.       IF enForces>0 THEN
  774.         PutStr("(weap "); PutInt(weapons[ENEMY],2); PutStr(") ");
  775.       ELSE
  776.         PutStr("          ");
  777.       END;
  778.       PutStr("sur: "); PutReal(enodds*100.0,3,0);
  779.       SetCursorPos(1,20);
  780.       PutStr("player"); PutInt(plForces,6);
  781.       IF plForces>0 THEN
  782.         PutStr("(weap "); PutInt(weapons[player],2); PutStr(") ");
  783.       ELSE
  784.         PutStr("          ");
  785.       END;
  786.       PutStr("sur: "); PutReal(plodds*100.0,3,0);
  787.     END;
  788.   END DisplayForces;
  789.  
  790.  
  791.  
  792. PROCEDURE OnBoard(x,y: IntType);
  793.   VAR
  794.     i: IntType;
  795.     starnum: IntType;
  796.   BEGIN
  797.     board[x][y].tf:=" ";
  798.     i:=1;
  799.     REPEAT
  800.       IF (tf[player][i].dest#0) AND (tf[player][i].x=x) AND (tf[player][i].y=y) THEN
  801.         IF board[x][y].tf=" " THEN
  802.           board[x][y].tf:=CHAR(i+IntType("a")-1);
  803.         ELSE
  804.           board[x][y].tf:="*";
  805.           i:=26;
  806.         END;
  807.       END;
  808.       INC(i);
  809.     UNTIL i>26;
  810.  
  811.     IF board[x][y].star#"." THEN
  812.       board[x][y].enemy:=" ";
  813.       starnum:=(IntType(board[x][y].star)-IntType("A"))+1;
  814.       IF colStars[starnum][player]#0 THEN
  815.         board[x][y].enemy:="@";
  816.       END;
  817.     END;
  818.     UpdateBoard(x,y,both);
  819.   END OnBoard;
  820.  
  821.  
  822.  
  823. PROCEDURE Lose(VAR ships: IntType;
  824.                VAR loseNone: BOOLEAN;
  825.                    typ: CHAR;
  826.                    percent: LONGREAL);
  827.   VAR
  828.     i,sleft: IntType;
  829.   BEGIN
  830.     IF ships>0 THEN
  831.       sleft:=ships;
  832.       FOR i:=1 TO ships DO
  833.         IF LONGREAL(RN.Random())>percent THEN
  834.           loseNone:=FALSE;
  835.           DEC(sleft);
  836.         END;
  837.       END;
  838.       IF sleft<ships THEN
  839.         PutCh(" ");
  840.         PutInt(ships-sleft,2);
  841.         PutCh(typ);
  842.         ships:=sleft;
  843.       END;
  844.     END;
  845.   END Lose;
  846.  
  847.  
  848.  
  849. PROCEDURE FireSalvo(    attackTeam: Team;
  850.                      VAR task: TaskForce;
  851.                          tfnum: IntType;
  852.                          planet: PlanetPtr;
  853.                          firstTime: BOOLEAN);
  854.   VAR
  855.     bases,attackForces,defendForces: IntType;
  856.     aLoseNone,pLoseNone: BOOLEAN;
  857.     attackOdds,defendOdds,attackSave,defendSave: LONGREAL;
  858.     defendTeam: Team;
  859.   BEGIN
  860.     SetCursorPos(1,24);
  861.     PutStr(blankLine);
  862.  
  863.     IF attackTeam=ENEMY THEN
  864.       defendTeam:=player;
  865.     ELSE
  866.       defendTeam:=ENEMY;
  867.     END;
  868.  
  869.     attackForces:=weapons[attackTeam]*(task.c*cruiserGuns+task.b*battleShipGuns);
  870.     defendForces:=weapons[defendTeam]*(planet^.mb*cruiserGuns+planet^.amb*battleShipGuns);
  871.  
  872.     IF defendForces>0 THEN
  873.       attackOdds:=fmin(LONGREAL(defendForces)/LONGREAL(attackForces),14.0);
  874.       attackSave:=MLL.exp(MLL.log(0.8)*attackOdds);
  875.       defendOdds:=fmin(LONGREAL(attackForces)/LONGREAL(defendForces),14.0);
  876.       defendSave:=MLL.exp(MLL.log(0.8)*defendOdds);
  877.  
  878.       SetCursorPos(1,20);
  879.       IF attackTeam=player THEN
  880.         PutStr("TF"); PutCh(CHAR(tfnum+IntType("a")-1));
  881.       ELSE
  882.         PutStr("ENE");
  883.       END;
  884.  
  885.       PutStr(":"); PutInt(attackForces,5);
  886.       PutStr("(weap "); PutInt(weapons[attackTeam],2);
  887.       PutStr(")sur: "); PutReal(attackSave*100.0,4,0);
  888.       SetCursorPos(1,21);
  889.       PutCh(" ");
  890.       PutCh(CHAR(planet^.pstar+IntType("A")-1)); PutInt(planet^.number,1);
  891.       PutCh(":"); PutInt(defendForces,5);
  892.       PutStr("(weap "); PutInt(weapons[defendTeam],2);
  893.       PutStr(")sur: "); PutReal(defendSave*100.0,4,0);
  894.       SetCursorPos(1,22); PutStr("Attacker losses:              ");
  895.       SetCursorPos(1,23); PutStr("Planet losses  :              ");
  896.  
  897.       aLoseNone:=TRUE;
  898.       pLoseNone:=TRUE;
  899.       REPEAT
  900.         SetCursorPos(18,22);
  901.         Lose(task.c,aLoseNone,"c",attackSave);
  902.         Lose(task.b,aLoseNone,"b",attackSave);
  903.         bases:=planet^.mb;
  904.         SetCursorPos(18,23);
  905.         Lose(planet^.mb,pLoseNone,"m",defendSave);
  906.         IF planet^.mb#bases THEN
  907.           PutStr("b");
  908.         END;
  909.         bases:=planet^.amb;
  910.         Lose(planet^.amb,pLoseNone,"a",defendSave);
  911.         IF planet^.amb#bases THEN
  912.           PutStr("mb");
  913.         END;
  914.       UNTIL NOT ((NOT firstTime) AND pLoseNone AND aLoseNone);
  915.  
  916.       IF aLoseNone THEN
  917.         SetCursorPos(18,22);
  918.         PutStr("(none)");
  919.       END;
  920.  
  921.       IF pLoseNone THEN
  922.         SetCursorPos(18,23);
  923.         PutStr("(none)");
  924.       END;
  925.     END;
  926.  
  927.     IF (planet^.mb+planet^.amb=0) AND AnyWarShip(attackTeam,planet^.pstar) THEN
  928.       SetCursorPos(1,24);
  929.       PutStr("Planet "); PutInt(planet^.number,1);
  930.       PutStr("falls!               ");
  931.       planet^.team:=attackTeam;
  932.       planet^.eSeeTeam:=attackTeam;
  933.       planet^.conquered:=TRUE;
  934.       DEC(colStars[task.dest][defendTeam]);
  935.       INC(colStars[task.dest][attackTeam]);
  936.       SetCursorPos(50,1);
  937.       PrintStar(planet^.pstar);
  938.       ClearField();
  939.       OnBoard(stars[task.dest].x,stars[task.dest].y);
  940.     END;
  941.   END FireSalvo;
  942.  
  943.  
  944.  
  945. PROCEDURE Revolt(starnum: IntType);
  946.   VAR
  947.     pplanet: PlanetPtr;
  948.     loses,getsBack: Team;
  949.   BEGIN
  950.     pplanet:=stars[starnum].firstPlanet;
  951.     IF colStars[starnum][ENEMY]+colStars[starnum][player]>0 THEN
  952.       WHILE pplanet#NIL DO
  953.         IF pplanet^.conquered THEN
  954.           IF (pplanet^.team=player) AND (NOT AnyWarShip(player,starnum)) THEN
  955.             loses:=player;
  956.             getsBack:=ENEMY;
  957.           ELSIF (pplanet^.team=ENEMY) AND (NOT AnyWarShip(ENEMY,starnum)) THEN
  958.             loses:=ENEMY;
  959.             getsBack:=player;
  960.           ELSE
  961.             loses:=none;
  962.           END;
  963.           IF loses#none THEN
  964.             DEC(colStars[starnum][loses]);
  965.             INC(colStars[starnum][getsBack]);
  966.             pplanet^.team:=getsBack;
  967.             pplanet^.conquered:=FALSE;
  968.             pplanet^.pSeeCapacity:=pplanet^.capacity;
  969.             OnBoard(stars[starnum].x,stars[starnum].y);
  970.           END;
  971.         END;
  972.         pplanet:=pplanet^.next;
  973.       END;
  974.     END;
  975.   END Revolt;
  976.  
  977.  
  978.  
  979. PROCEDURE EnemyAttack(starnum: IntType);
  980.   VAR
  981.     attackFact,defenseFact: IntType;
  982.     odds,bestScore: LONGREAL;
  983.     pplanet,bestPlanet: PlanetPtr;
  984.     enTF,i: IntType;
  985.     first: ARRAY[0..8] OF BOOLEAN;
  986.   BEGIN
  987.     FOR i:=1 TO 7 DO
  988.       first[i]:=TRUE;
  989.     END;
  990.  
  991.     enTF:=1;
  992.     WHILE (tf[ENEMY][enTF].dest#starnum) OR (tf[ENEMY][enTF].eta#0) DO
  993.       INC(enTF);
  994.     END;
  995.  
  996.     REPEAT
  997.       attackFact:=tf[ENEMY][enTF].c+6*tf[ENEMY][enTF].b;
  998.       bestPlanet:=NIL;
  999.       bestScore:=1000.0;
  1000.       pplanet:=stars[starnum].firstPlanet;
  1001.       WHILE pplanet#NIL DO
  1002.         IF pplanet^.team=player THEN
  1003.           defenseFact:=pplanet^.eSeeDefend;
  1004.           odds:=LONGREAL(defenseFact)/LONGREAL(attackFact);
  1005.           IF pplanet^.capacity>30 THEN
  1006.             odds:=(odds-2.0)*LONGREAL(pplanet^.capacity);
  1007.           ELSE
  1008.             odds:=(odds-1.5)*LONGREAL(pplanet^.capacity);
  1009.           END;
  1010.           IF odds<bestScore THEN
  1011.             bestScore:=odds;
  1012.             bestPlanet:=pplanet;
  1013.           END;
  1014.         END;
  1015.         pplanet:=pplanet^.next;
  1016.       END;
  1017.       IF bestScore<0.0 THEN
  1018.         ClearLeft();
  1019.         SetCursorPos(1,19);
  1020.         PutStr("Enemy attacks: ");
  1021.         PutCh(CHAR(starnum+IntType("A")-1));
  1022.         PutInt(bestPlanet^.number,1);
  1023.         SetCursorPos(50,1);
  1024.         PrintStar(starnum);
  1025.         ClearField();
  1026.         Pause;
  1027.         FireSalvo(ENEMY,tf[ENEMY][enTF],0,bestPlanet,first[bestPlanet^.number]);
  1028.         first[bestPlanet^.number]:=FALSE;
  1029.         ZeroTF(ENEMY,enTF);
  1030.         bestPlanet^.eSeeDefend:=bestPlanet^.mb+6*bestPlanet^.amb;
  1031.         Pause;
  1032.       END;
  1033.     UNTIL (bestScore>=0.0) OR (NOT AnyWarShip(ENEMY,starnum));
  1034.     Revolt(starnum);
  1035.   END EnemyAttack;
  1036.  
  1037.  
  1038.  
  1039. PROCEDURE GetTF(tm: Team; VAR i: IntType; starnum: IntType);
  1040.   BEGIN
  1041.     i:=1;
  1042.     WHILE (tf[tm][i].dest#0) AND (i<27) DO
  1043.       INC(i);
  1044.     END;
  1045.     IF i=27 THEN
  1046.       i:=0;
  1047.     ELSE
  1048.       tf[tm][i].s:=0;
  1049.       tf[tm][i].t:=0;
  1050.       tf[tm][i].c:=0;
  1051.       tf[tm][i].b:=0;
  1052.       tf[tm][i].eta:=0;
  1053.       tf[tm][i].x:=stars[starnum].x;
  1054.       tf[tm][i].y:=stars[starnum].y;
  1055.       tf[tm][i].xf:=tf[tm][i].x;
  1056.       tf[tm][i].yf:=tf[tm][i].y;
  1057.       tf[tm][i].dest:=starnum;
  1058.       tf[tm][i].origeta:=0;
  1059.       tf[tm][i].blasting:=FALSE;
  1060.     END;
  1061.   END GetTF;
  1062.  
  1063.  
  1064.  
  1065. PROCEDURE JoinSilent(team: Team; VAR parent,child: TaskForce);
  1066.   BEGIN
  1067.     parent.t:=parent.t+child.t;
  1068.     parent.s:=parent.s+child.s;
  1069.     parent.c:=parent.c+child.c;
  1070.     parent.b:=parent.b+child.b;
  1071.     IF (parent.dest#0) AND (child.dest#0) THEN
  1072.       DEC(tfStars[parent.dest][team]);
  1073.     END;
  1074.     child.dest:=0;
  1075.   END JoinSilent;
  1076.  
  1077.  
  1078.  
  1079. PROCEDURE ErrorMessage;
  1080.   BEGIN
  1081.     SetCursorPos(1,24);
  1082.   END ErrorMessage;
  1083.  
  1084.  
  1085.  
  1086. PROCEDURE PlayerSalvo(starnum: IntType; VAR battle: BOOLEAN);
  1087.   VAR
  1088.     tfCh,plCh: CHAR;
  1089.     plNum,tfNum: IntType;
  1090.     found: BOOLEAN;
  1091.     pl: PlanetPtr;
  1092.     first: BOOLEAN;
  1093.   BEGIN
  1094.     PutStr("Attack planet ");
  1095.     pl:=stars[starnum].firstPlanet;
  1096.     IF (colStars[starnum][ENEMY]>1) THEN
  1097.       PutStr(":");
  1098.       GetChar(plCh);
  1099.       ClearLeft();
  1100.       plNum:=IntType(plCh)-IntType("0");
  1101.  
  1102.       found:=FALSE;
  1103.       WHILE NOT found DO
  1104.         IF pl^.number=plNum THEN
  1105.           found:=TRUE;
  1106.         ELSE
  1107.           IF pl^.next=NIL THEN
  1108.             found:=TRUE;
  1109.           ELSE
  1110.             pl:=pl^.next;
  1111.           END;
  1112.         END;
  1113.       END;
  1114.  
  1115.       IF pl^.number#plNum THEN
  1116.         plNum:=0;
  1117.         ErrorMessage();
  1118.         PutStr("!that is not a useable planet");
  1119.       ELSIF pl^.team#ENEMY THEN
  1120.         ErrorMessage();
  1121.         PutStr("!that is not an enemy colony");
  1122.         plNum:=0;
  1123.       END;
  1124.     ELSE
  1125.       WHILE pl^.team#ENEMY DO
  1126.         pl:=pl^.next;
  1127.       END;
  1128.       PutInt(pl^.number,1);
  1129.       ClearLeft();
  1130.       plNum:=pl^.number;
  1131.     END;
  1132.  
  1133.     IF plNum#0 THEN
  1134.       SetCursorPos(1,19); PutStr(" attacking tf ");
  1135.       IF tfStars[starnum][player]>1 THEN
  1136.         PutStr(":");
  1137.         GetChar(tfCh);
  1138.         tfNum:=IntType(tfCh)-IntType("A")+1;
  1139.       ELSE
  1140.         tfNum:=1;
  1141.         WHILE (tf[player][tfNum].dest#starnum) OR (tf[player][tfNum].eta#0) DO
  1142.           INC(tfNum);
  1143.         END;
  1144.         PutCh(CHAR(tfNum+IntType("a")-1));
  1145.       END;
  1146.  
  1147.       IF (tfNum<1) OR (tfNum>26) THEN
  1148.         ErrorMessage();
  1149.         PutStr(" !illegal tf");
  1150.       ELSIF tf[player][tfNum].dest=0 THEN
  1151.         ErrorMessage();
  1152.         PutStr(" !nonexistant tf");
  1153.       ELSIF (tf[player][tfNum].dest#starnum) OR (tf[player][tfNum].eta#0) THEN
  1154.         ErrorMessage();
  1155.         PutStr(" !tf is not at this star      ");
  1156.       ELSIF tf[player][tfNum].b+tf[player][tfNum].c=0 THEN
  1157.         ErrorMessage();
  1158.         PutStr(" !tf has no warships");
  1159.       ELSE
  1160.         first:=NOT pl^.underAttack;
  1161.         IF first THEN
  1162.           pl^.underAttack:=TRUE;
  1163.           SetCursorPos(50,1);
  1164.           PrintStar(starnum);
  1165.           ClearField();
  1166.         END;
  1167.         FireSalvo(player,tf[player][tfNum],tfNum,pl,first);
  1168.         ZeroTF(player,tfNum);
  1169.         battle:=(colStars[starnum][ENEMY]>0) AND (AnyWarShip(player,starnum));
  1170.       END;
  1171.     END;
  1172.   END PlayerSalvo;
  1173.  
  1174.  
  1175.  
  1176. PROCEDURE PrintColony;
  1177.   VAR
  1178.     i: IntType;
  1179.     pplanet: PlanetPtr;
  1180.   BEGIN
  1181.     PutStr("olonies:");
  1182.     SetCursorPos(50,1);
  1183.  
  1184.     FOR i:=1 TO nstars DO
  1185.       pplanet:=stars[i].firstPlanet;
  1186.       WHILE pplanet#NIL DO
  1187.         IF pplanet^.team=player THEN
  1188.           PutCh(CHAR(i+IntType("A")-1));
  1189.           PrintPlanet(pplanet,TRUE);
  1190.         END;
  1191.         pplanet:=pplanet^.next;
  1192.       END;
  1193.     END;
  1194.     ClearField();
  1195.     ClearLeft();
  1196.   END PrintColony;
  1197.  
  1198.  
  1199.  
  1200. PROCEDURE StarSummary;
  1201.   VAR
  1202.     iline: Line;
  1203.     ind,i,value: IntType;
  1204.     strs: CHAR;
  1205.   BEGIN
  1206.     PutStr("tar summary:");
  1207.     ClearLeft();
  1208.     SetCursorPos(1,19);
  1209.     PutCh(':');
  1210.  
  1211.     GetLine(iline,ind,TRUE);
  1212.     GetToken(iline,ind,value,strs);
  1213.     SetCursorPos(50,1);
  1214.     IF strs=" " THEN
  1215.       FOR i:=1 TO nstars DO
  1216.         PrintStar(i);
  1217.       END;
  1218.     ELSE
  1219.       REPEAT
  1220.         i:=IntType(strs)-IntType("A")+1;
  1221.         PrintStar(i);
  1222.         GetToken(iline,ind,value,strs);
  1223.       UNTIL strs=" ";
  1224.     END;
  1225.     ClearField();
  1226.   END StarSummary;
  1227.  
  1228.  
  1229.  
  1230. PROCEDURE PrintTF(i: IntType);
  1231.   VAR
  1232.     x,y: IntType;
  1233.   BEGIN
  1234.     IF (i>0) AND (i<=26) THEN
  1235.  
  1236.       IF tf[player][i].dest#0 THEN
  1237.         PutStr("TF"); PutCh(CHAR(i+IntType("a")-1)); PutCh(":");
  1238.         x:=tf[player][i].x; y:=tf[player][i].y;
  1239.         IF tf[player][i].eta=0 THEN
  1240.           PutCh(CHAR(tf[player][i].dest+IntType("A")-1));
  1241.         ELSE
  1242.           PutCh(" ");
  1243.         END;
  1244.         PutCh("("); PutInt(x,2);
  1245.         PutCh(","); PutInt(y,2);
  1246.         PutStr(")                 ");
  1247.         SetCursorPos(cursor.x+14,cursor.y);
  1248.         cursor.x:=cursor.x-14;
  1249.         DisplayTF(tf[player][i]);
  1250.         IF tf[player][i].eta#0 THEN
  1251.           PutStr("\x9b7m"); (* reverse on *)
  1252.           PutCh(CHAR(tf[player][i].dest+IntType("A")-1));
  1253.           PutInt(tf[player][i].eta,0);
  1254.           PutStr("\x9b0m"); (* back to normal text *)
  1255.         END;
  1256.         SetCursorPos(cursor.x,cursor.y+1);
  1257.       END;
  1258.     END;
  1259.   END PrintTF;
  1260.  
  1261.  
  1262.  
  1263. PROCEDURE TFSummary;
  1264.   VAR
  1265.     i,value: IntType;
  1266.     tfs: CHAR;
  1267.     iline: Line;
  1268.     ind: IntType;
  1269.   BEGIN
  1270.     PutStr("f summary :");
  1271.     GetLine(iline,ind,TRUE);
  1272.     GetToken(iline,ind,value,tfs);
  1273.     SetCursorPos(50,1);
  1274.     IF tfs=" " THEN
  1275.       FOR i:=1 TO 26 DO
  1276.         PrintTF(i);
  1277.         IF cursor.y+3>19 THEN
  1278.           ClearField();
  1279.           Pause;
  1280.           SetCursorPos(50,1);
  1281.         END;
  1282.       END;
  1283.     ELSE
  1284.       REPEAT
  1285.         i:=IntType(tfs)-IntType("A")+1;
  1286.         PrintTF(i);
  1287.         IF cursor.y+3>19 THEN
  1288.           ClearField();
  1289.           Pause;
  1290.           SetCursorPos(50,1);
  1291.         END;
  1292.         GetToken(iline,ind,value,tfs);
  1293.       UNTIL tfs=" ";
  1294.     END;
  1295.     ClearField();
  1296.     ClearLeft();
  1297.   END TFSummary;
  1298.  
  1299.  
  1300.  
  1301. PROCEDURE Help(which: IntType);
  1302.   BEGIN
  1303.     CASE which OF
  1304.       |0: SetCursorPos(50, 1); PutStr("(B)    Build Battlestar  75");
  1305.           SetCursorPos(50, 2); PutStr("(C)    Build Cruiser     16");
  1306.           SetCursorPos(50, 3); PutStr("(H)    Help");
  1307.           SetCursorPos(50, 4); PutStr("(R)    Range Research     1");
  1308.           SetCursorPos(50, 5); PutStr("(S)    Build Scout        6");
  1309.           SetCursorPos(50, 6); PutStr("(V)    Velocity Research  1");
  1310.           SetCursorPos(50, 7); PutStr("(W)    Weapons Research   1");
  1311.           SetCursorPos(50, 8); PutStr("(>)(M) Redraw Map");
  1312.           SetCursorPos(50, 9); PutStr("(>)(R) Research summary");
  1313.  
  1314.       |1: SetCursorPos(50, 1); PutStr("(B) Blast Planet");
  1315.           SetCursorPos(50, 2); PutStr("(C) Colony summary");
  1316.           SetCursorPos(50, 3); PutStr("(D) Taskforce Destination");
  1317.           SetCursorPos(50, 4); PutStr("(G) Go on (done)");
  1318.           SetCursorPos(50, 5); PutStr("(H) Help");
  1319.           SetCursorPos(50, 6); PutStr("(J) Join Taskforces");
  1320.           SetCursorPos(50, 7); PutStr("(L) Land transports");
  1321.           SetCursorPos(50, 8); PutStr("(M) Redraw Map");
  1322.           SetCursorPos(50, 9); PutStr("(N) New Taskforce");
  1323.           SetCursorPos(50,10); PutStr("(Q) Quit");
  1324.           SetCursorPos(50,11); PutStr("(R) Research summary");
  1325.           SetCursorPos(50,12); PutStr("(S) Star summary");
  1326.           SetCursorPos(50,13); PutStr("(T) Taskforce summary");
  1327.  
  1328.       |2: SetCursorPos(50, 1); PutStr("(C) Colonies");
  1329.           SetCursorPos(50, 2); PutStr("(G) Go on (done)");
  1330.           SetCursorPos(50, 3); PutStr("(H) Help");
  1331.           SetCursorPos(50, 4); PutStr("(M) Redraw Map");
  1332.           SetCursorPos(50, 5); PutStr("(O) Odds");
  1333.           SetCursorPos(50, 6); PutStr("(R) Research summary");
  1334.           SetCursorPos(50, 7); PutStr("(S) Star summary");
  1335.           SetCursorPos(50, 8); PutStr("(T) Taskforce summary");
  1336.           SetCursorPos(50, 9); PutStr("(W) Withdraw");
  1337.  
  1338.       |3: SetCursorPos(50, 1); PutStr("(B) Break off Attack");
  1339.           SetCursorPos(50, 2); PutStr("(C) Colony summary");
  1340.           SetCursorPos(50, 3); PutStr("(G) Go on (done)");
  1341.           SetCursorPos(50, 4); PutStr("(H) Help");
  1342.           SetCursorPos(50, 5); PutStr("(J) Join Taskforces");
  1343.           SetCursorPos(50, 6); PutStr("(M) Redraw Map");
  1344.           SetCursorPos(50, 7); PutStr("(N) New Taskforce");
  1345.           SetCursorPos(50, 8); PutStr("(R) Research summary");
  1346.           SetCursorPos(50, 9); PutStr("(S) Star summary");
  1347.           SetCursorPos(50,10); PutStr("(T) Taskforce summary");
  1348.  
  1349.       |4: SetCursorPos(50, 1); PutStr("(A)    Bld Advanced M. Base 35");
  1350.           SetCursorPos(50, 2); PutStr("(B)    Build Battlestar     70");
  1351.           SetCursorPos(50, 3); PutStr("(C)    Build Cruiser        16");
  1352.           SetCursorPos(50, 4); PutStr("(H)    Help");
  1353.           SetCursorPos(50, 5); PutStr("(I)    Invest                3");
  1354.           SetCursorPos(50, 6); PutStr("(M)    Build Missile Base    8");
  1355.           SetCursorPos(50, 7); PutStr("(R)    Range Research        1");
  1356.           SetCursorPos(50, 8); PutStr("(S)    Build Scout           6");
  1357.           SetCursorPos(50, 9); PutStr("(T)    Build Transport       1");
  1358.           SetCursorPos(50,10); PutStr("(V)    Velocity Research     1");
  1359.           SetCursorPos(50,11); PutStr("(W)    Weapons Research      1");
  1360.           SetCursorPos(50,12); PutStr("(>)(C) Colony summary");
  1361.           SetCursorPos(50,13); PutStr("(>)(M) Redraw Map");
  1362.           SetCursorPos(50,14); PutStr("(>)(R) Research summary");
  1363.           SetCursorPos(50,15); PutStr("(>)(S) Star summary");
  1364.     END;
  1365.     ClearField();
  1366.   END Help;
  1367.  
  1368.  
  1369.  
  1370. PROCEDURE SplitTF(VAR tfNum,newTF: IntType);
  1371.   VAR
  1372.     ships: CHAR;
  1373.     x,y,numShips: IntType;
  1374.     ind: IntType;
  1375.     iline: Line;
  1376.   BEGIN
  1377.     GetTF(player,newTF,tf[player][tfNum].dest);
  1378.     INC(tfStars[tf[player][tfNum].dest][player]);
  1379.     PutStr(" ships: ");
  1380.     SetCursorPos(9,cursor.y);
  1381.     GetLine(iline,ind,FALSE);
  1382.     GetToken(iline,ind,numShips,ships);
  1383.     IF ships=" " THEN
  1384.       (* entire fleet *)
  1385.       tf[player][newTF].s:=tf[player][tfNum].s;
  1386.       tf[player][newTF].t:=tf[player][tfNum].t;
  1387.       tf[player][newTF].c:=tf[player][tfNum].c;
  1388.       tf[player][newTF].b:=tf[player][tfNum].b;
  1389.       tf[player][tfNum].s:=0;
  1390.       tf[player][tfNum].t:=0;
  1391.       tf[player][tfNum].c:=0;
  1392.       tf[player][tfNum].b:=0;
  1393.     ELSE
  1394.       REPEAT
  1395.         CASE ships OF
  1396.           |"T": IF tf[player][tfNum].t<numShips THEN
  1397.                   numShips:=tf[player][tfNum].t;
  1398.                 END;
  1399.                 tf[player][tfNum].t:=tf[player][tfNum].t-numShips;
  1400.                 tf[player][newTF].t:=tf[player][newTF].t+numShips;
  1401.           |"S": IF tf[player][tfNum].s<numShips THEN
  1402.                   numShips:=tf[player][tfNum].s;
  1403.                 END;
  1404.                 tf[player][tfNum].s:=tf[player][tfNum].s-numShips;
  1405.                 tf[player][newTF].s:=tf[player][newTF].s+numShips;
  1406.           |"C": IF tf[player][tfNum].c<numShips THEN
  1407.                   numShips:=tf[player][tfNum].c;
  1408.                 END;
  1409.                 tf[player][tfNum].c:=tf[player][tfNum].c-numShips;
  1410.                 tf[player][newTF].c:=tf[player][newTF].c+numShips;
  1411.           |"B": IF tf[player][tfNum].b<numShips THEN
  1412.                   numShips:=tf[player][tfNum].b;
  1413.                 END;
  1414.                 tf[player][tfNum].b:=tf[player][tfNum].b-numShips;
  1415.                 tf[player][newTF].b:=tf[player][newTF].b+numShips;
  1416.           |ELSE ErrorMessage();
  1417.                 PutStr("  !Illegal field "); PutCh(ships);
  1418.         END;
  1419.         GetToken(iline,ind,numShips,ships);
  1420.       UNTIL ships=" ";
  1421.     END;
  1422.     x:=tf[player][tfNum].x;
  1423.     y:=tf[player][tfNum].y;
  1424.     ZeroTF(player,tfNum);
  1425.     ZeroTF(player,newTF);
  1426.     OnBoard(x,y);
  1427.   END SplitTF;
  1428.  
  1429.  
  1430.  
  1431. PROCEDURE MakeTF;
  1432.   VAR
  1433.     tfCh: CHAR;
  1434.     tfNum: IntType;
  1435.     error: BOOLEAN;
  1436.     newTF: IntType;
  1437.   BEGIN
  1438.     PutStr("ew tf- from tf: ");
  1439.     GetChar(tfCh);
  1440.     ClearLeft();
  1441.     tfNum:=IntType(tfCh)-IntType("A")+1;
  1442.     error:=(tfNum<1) OR (tfNum>26);
  1443.     IF NOT error THEN
  1444.       error:=(tf[player][tfNum].eta#0) OR (tf[player][tfNum].dest=0);
  1445.     END;
  1446.     IF error THEN
  1447.       ErrorMessage();
  1448.       PutStr("  !illegal tf");
  1449.     ELSIF tf[player][tfNum].blasting THEN
  1450.       error:=TRUE;
  1451.       ErrorMessage();
  1452.       PutStr(" !Tf is blasting a planet     ");
  1453.     ELSE
  1454.       SetCursorPos(1,19);
  1455.       SplitTF(tfNum,newTF);
  1456.       SetCursorPos(1,20);
  1457.       PrintTF(newTF);
  1458.       SetCursorPos(1,21);
  1459.       PrintTF(tfNum);
  1460.     END;
  1461.   END MakeTF;
  1462.  
  1463.  
  1464.  
  1465. PROCEDURE JoinTF;
  1466.   VAR
  1467.     tf1,tf2: CHAR;
  1468.     tf1n,tf2n,ind,value: IntType;
  1469.     iline: Line;
  1470.   BEGIN
  1471.     PutStr("oin tfs:");
  1472.     ind:=1;
  1473.     GetLine(iline,ind,TRUE);
  1474.     ClearLeft();
  1475.     GetToken(iline,ind,value,tf1);
  1476.     tf1n:=IntType(tf1)-IntType("A")+1;
  1477.     IF (tf1n<1) OR (tf1n>26) THEN
  1478.       ErrorMessage();
  1479.       PutStr(" !illegal taskforce "); PutCh(tf1);
  1480.     ELSIF tf[player][tf1n].eta>0 THEN
  1481.       ErrorMessage();
  1482.       PutStr(" !tf"); PutCh(tf1); PutStr(" is not in normal space ");
  1483.     ELSIF tf[player][tf1n].dest=0 THEN
  1484.       ErrorMessage();
  1485.       PutStr(" !nonexistant taskforce "); PutCh(tf1);
  1486.     ELSIF tf[player][tf1n].blasting THEN
  1487.       ErrorMessage();
  1488.       PutStr(" !tf"); PutCh(tf1); PutStr(" is blasting a planet    ");
  1489.     ELSE
  1490.       GetToken(iline,ind,value,tf2);
  1491.       REPEAT
  1492.         tf2n:=IntType(tf2)-IntType("A")+1;
  1493.         IF (tf2n<1) OR (tf2n>26) THEN
  1494.           ErrorMessage();
  1495.           PutStr(" !illegal taskforce "); PutCh(tf2);
  1496.         ELSIF tf2n=tf1n THEN
  1497.           ErrorMessage();
  1498.           PutStr(" !duplicate taskforce "); PutCh(tf2);
  1499.         ELSIF tf[player][tf2n].dest=0 THEN
  1500.           ErrorMessage();
  1501.           PutStr(" !nonexistant taskforce "); PutCh(tf2);
  1502.         ELSIF (tf[player][tf2n].x#tf[player][tf1n].x) OR (tf[player][tf2n].y#tf[player][tf2n].y) THEN
  1503.           ErrorMessage();
  1504.           PutStr(" !tf"); PutCh(tf2); PutStr(" bad location");
  1505.         ELSIF tf[player][tf2n].eta#0 THEN
  1506.           ErrorMessage();
  1507.           PutStr(" !tf"); PutCh(tf2); PutStr(" is not in normal space ");
  1508.         ELSIF tf[player][tf2n].blasting THEN
  1509.           ErrorMessage();
  1510.           PutStr(" !tf"); PutCh(tf2); PutStr(" is blasting a planet    ");
  1511.         ELSE
  1512.           JoinSilent(player,tf[player][tf1n],tf[player][tf2n]);
  1513.         END;
  1514.         GetToken(iline,ind,value,tf2);
  1515.       UNTIL tf2=" ";
  1516.       OnBoard(tf[player][tf1n].x,tf[player][tf1n].y);
  1517.       SetCursorPos(1,19);
  1518.       PrintTF(tf1n);
  1519.     END;
  1520.   END JoinTF;
  1521.  
  1522.  
  1523.  
  1524. PROCEDURE PlayerAttack(starnum: IntType);
  1525.   VAR
  1526.     battle: BOOLEAN;
  1527.     command: CHAR;
  1528.     pplanet: PlanetPtr;
  1529.   BEGIN
  1530.     battle:=AnyWarShip(player,starnum);
  1531.     IF battle THEN
  1532.       SetCursorPos(32,20);
  1533.       PutStr("Attack at star ");
  1534.       PutCh(CHAR(starnum+IntType("A")-1));
  1535.       WHILE battle DO
  1536.         SetCursorPos(50,1);
  1537.         PrintStar(starnum);
  1538.         ClearField();
  1539.         SetCursorPos(1,18);
  1540.         PutStr("P?                            ");
  1541.         SetCursorPos(4,18);
  1542.         GetChar(command);
  1543.         CASE command OF
  1544.           |"S": StarSummary();
  1545.           |"M": PrintMap();
  1546.           |"H": Help(3);
  1547.                 Pause;
  1548.           |"N": MakeTF();
  1549.           |"J": JoinTF();
  1550.           |"C": PrintColony();
  1551.           |"R": ResearchSummary();
  1552.           |"T": TFSummary();
  1553.           |" ",
  1554.            "G": PlayerSalvo(starnum,battle);
  1555.           |"B": PutStr("reak off attack");
  1556.                 battle:=FALSE;
  1557.           |ELSE ClearLeft();
  1558.                 ErrorMessage();
  1559.                 PutStr(" !Illegal command");
  1560.         END;
  1561.       END;
  1562.       pplanet:=stars[starnum].firstPlanet;
  1563.       WHILE pplanet#NIL DO
  1564.         pplanet^.underAttack:=FALSE;
  1565.         pplanet:=pplanet^.next;
  1566.       END;
  1567.       SetCursorPos(1,24);
  1568.       PutStr("Planet attack concluded       ");
  1569.       Revolt(starnum);
  1570.     END;
  1571.   END PlayerAttack;
  1572.  
  1573.  
  1574.  
  1575. PROCEDURE SetDestination(tfNum: IntType; VAR error: BOOLEAN);
  1576.   VAR
  1577.     starNum,minETA: IntType;
  1578.     istar: CHAR;
  1579.     r: LONGREAL;
  1580.     rge,dst: IntType;
  1581.     fromStar: IntType;
  1582.   BEGIN
  1583.     error:=TRUE;
  1584.     IF (tf[player][tfNum].eta#0) THEN
  1585.       (* cancel *)
  1586.       tf[player][tfNum].eta:=0;
  1587.       fromStar:=IntType(board[tf[player][tfNum].x][tf[player][tfNum].y].star)-IntType("A")+1;
  1588.       tf[player][tfNum].dest:=fromStar;
  1589.       INC(tfStars[fromStar][player]);
  1590.       PutStr("(Cancelling previous orders)");
  1591.       SetCursorPos(1,cursor.y+1);
  1592.     END;
  1593.     error:=TRUE;
  1594.     PutStr(" to star: ");
  1595.     SetCursorPos(11,cursor.y);
  1596.     GetChar(istar);
  1597.     starNum:=IntType(istar)-IntType("A")+1;
  1598.     IF (starNum<0) OR (starNum>nstars) THEN
  1599.       ErrorMessage();
  1600.       PutStr("  !illegal star");
  1601.     ELSE
  1602.       r:=MLL.sqrt(LONGREAL((stars[starNum].x-tf[player][tfNum].x)*(stars[starNum].x-tf[player][tfNum].x)+
  1603.                            (stars[starNum].y-tf[player][tfNum].y)*(stars[starNum].y-tf[player][tfNum].y)));
  1604.       SetCursorPos(1,cursor.y+1);
  1605.       PutStr("   distance:"); PutReal(r,5,1);
  1606.       dst:=IntType(r-0.09999999999+1.0);
  1607.       IF (dst>curRange[player]) AND
  1608.          ((tf[player][tfNum].b#0) OR (tf[player][tfNum].c#0) OR (tf[player][tfNum].t#0)) THEN
  1609.         ErrorMessage();
  1610.         PutStr("  !maximum range is"); PutInt(curRange[player],3);
  1611.       ELSIF r<0.5 THEN
  1612.         SetCursorPos(1,cursor.y+1);
  1613.         PutStr("Tf remains at star");
  1614.       ELSE
  1615.         minETA:=((dst-1) DIV vel[player])+1;
  1616.         SetCursorPos(1,cursor.y+1);
  1617.         PutStr("ETA in "); PutInt(minETA,0); PutStr(" turns");
  1618.         DEC(tfStars[tf[player][tfNum].dest][player]);
  1619.         tf[player][tfNum].dest:=starNum;
  1620.         tf[player][tfNum].eta:=minETA;
  1621.         tf[player][tfNum].origeta:=minETA;
  1622.         tf[player][tfNum].xf:=tf[player][tfNum].x;
  1623.         tf[player][tfNum].yf:=tf[player][tfNum].y;
  1624.         error:=FALSE;
  1625.       END;
  1626.     END;
  1627.   END SetDestination;
  1628.  
  1629.  
  1630.  
  1631. PROCEDURE WithDraw(starnum,plnum: IntType);
  1632.   VAR
  1633.     withnum: IntType;
  1634.     error: BOOLEAN;
  1635.   BEGIN
  1636.     PutStr("ithdraw ");
  1637.     ClearLeft();
  1638.     SetCursorPos(1,19);
  1639.     SplitTF(plnum,withnum);
  1640.     IF tf[player][withnum].dest#0 THEN
  1641.       SetCursorPos(1,20);
  1642.       SetDestination(withnum,error);
  1643.       IF error THEN
  1644.         tf[player][plnum].dest:=starnum;
  1645.         JoinSilent(player,tf[player][plnum],tf[player][withnum]);
  1646.         tfStars[starnum][player]:=1;
  1647.       ELSE
  1648.         tf[player][withnum].withdrew:=TRUE;
  1649.       END;
  1650.     END;
  1651.   END WithDraw;
  1652.  
  1653.  
  1654.  
  1655. PROCEDURE GetStars(sStar: IntType; VAR slist: RealStarList; VAR count: IntType);
  1656.   VAR
  1657.     starnum: IntType;
  1658.   BEGIN
  1659.     count:=0;
  1660.     FOR starnum:=1 TO nstars DO
  1661.       IF curRange[ENEMY]>=distance[sStar][starnum] THEN
  1662.         INC(count);
  1663.         slist[starnum]:=LONGREAL(distance[sStar][starnum]);
  1664.       ELSE
  1665.         slist[starnum]:=0.0;
  1666.       END;
  1667.     END;
  1668.   END GetStars;
  1669.  
  1670.  
  1671.  
  1672. PROCEDURE TFBattle(starnum: IntType);
  1673.   VAR
  1674.     ennum,plnum: IntType;
  1675.     enodds,plodds: LONGREAL;
  1676.     battle: BOOLEAN;
  1677.     count,newTF,i: IntType;
  1678.     ch: CHAR;
  1679.     playerLoss,enemyLoss: BOOLEAN;
  1680.     size: IntType;
  1681.     team: Team;
  1682.     dstar: IntType;
  1683.     slist: RealStarList;
  1684.     fin,first: BOOLEAN;
  1685.   BEGIN
  1686.     board[stars[starnum].x][stars[starnum].y].enemy:="!";
  1687.     UpdateBoard(stars[starnum].x,stars[starnum].y,left);
  1688.  
  1689.     ennum:=1;
  1690.     WHILE (tf[ENEMY][ennum].dest#starnum) OR (tf[ENEMY][ennum].eta#0) DO
  1691.       INC(ennum);
  1692.     END;
  1693.  
  1694.     plnum:=1;
  1695.     IF tfStars[starnum][player]>1 THEN
  1696.       GetTF(player,newTF,starnum);
  1697.       FOR i:=1 TO 26 DO
  1698.         IF (tf[player][i].dest=starnum) AND
  1699.            (tf[player][i].eta=0) AND
  1700.            (i#newTF) THEN
  1701.           JoinSilent(player,tf[player][newTF],tf[player][i]);
  1702.         END;
  1703.       END;
  1704.       tfStars[starnum][player]:=1;
  1705.       plnum:=newTF;
  1706.     ELSE
  1707.       WHILE (tf[player][plnum].dest#starnum) OR (tf[player][plnum].eta#0) DO
  1708.         INC(plnum);
  1709.       END;
  1710.     END;
  1711.  
  1712.     DisplayForces(ennum,plnum,enodds,plodds,battle);
  1713.     Pause;
  1714.  
  1715.     first:=TRUE;
  1716.     WHILE battle DO
  1717.       SetCursorPos(1,24);
  1718.       PutStr(blankLine);
  1719.       playerLoss:=TRUE;
  1720.       enemyLoss:=TRUE;
  1721.       SetCursorPos(1,21);
  1722.       PutStr(" Enemy losses:                ");
  1723.       SetCursorPos(1,22);
  1724.       PutStr("Player losses:                ");
  1725.       REPEAT
  1726.         SetCursorPos(16,21);
  1727.         Lose(tf[ENEMY][ennum].t,enemyLoss,"t",enodds);
  1728.         Lose(tf[ENEMY][ennum].s,enemyLoss,"s",enodds);
  1729.         Lose(tf[ENEMY][ennum].c,enemyLoss,"c",enodds);
  1730.         Lose(tf[ENEMY][ennum].b,enemyLoss,"b",enodds);
  1731.         SetCursorPos(16,22);
  1732.         Lose(tf[player][plnum].t,playerLoss,"t",plodds);
  1733.         Lose(tf[player][plnum].s,playerLoss,"s",plodds);
  1734.         Lose(tf[player][plnum].c,playerLoss,"c",plodds);
  1735.         Lose(tf[player][plnum].b,playerLoss,"b",plodds);
  1736.       UNTIL NOT ((NOT first) AND enemyLoss AND playerLoss);
  1737.  
  1738.       IF enemyLoss THEN
  1739.         SetCursorPos(16,21);
  1740.         PutStr("(none)");
  1741.       END;
  1742.  
  1743.       IF playerLoss THEN
  1744.         SetCursorPos(16,22);
  1745.         PutStr("(none)");
  1746.       END;
  1747.  
  1748.       first:=FALSE;
  1749.       DisplayForces(ennum,plnum,enodds,plodds,battle);
  1750.       IF battle THEN
  1751.         (* withdraw the bad guys *)
  1752.         GetTF(ENEMY,newTF,starnum);
  1753.         IF (tf[player][plnum].c>0) OR (tf[player][plnum].b>0) THEN
  1754.           tf[ENEMY][newTF].t:=tf[ENEMY][ennum].t;
  1755.           tf[ENEMY][newTF].s:=tf[ENEMY][ennum].s;
  1756.           FindBestPlan(starnum,size,team);
  1757.           IF ((enodds<0.7) AND (size<30)) OR
  1758.              ((enodds<0.5) AND (team=player)) OR
  1759.              ((enodds<0.3) AND (size<60)) OR
  1760.               (enodds < 0.20) THEN
  1761.             tf[ENEMY][newTF].c:=tf[ENEMY][ennum].c;
  1762.             tf[ENEMY][newTF].b:=tf[ENEMY][ennum].b;
  1763.           END;
  1764.         END;
  1765.  
  1766.         IF (tf[ENEMY][newTF].t+tf[ENEMY][newTF].s+
  1767.             tf[ENEMY][newTF].c+tf[ENEMY][newTF].b)>0 THEN
  1768.           GetStars(starnum,slist,count);
  1769.  
  1770.           REPEAT
  1771.             dstar:=RN.RND(nstars)+1;
  1772.           UNTIL slist[dstar]>0.0;
  1773.  
  1774.           tf[ENEMY][newTF].dest:=dstar;
  1775.           tf[ENEMY][newTF].eta:=IntType((slist[dstar]-0.01)/LONGREAL(vel[ENEMY]))+1;
  1776.           tf[ENEMY][newTF].xf:=stars[starnum].x;
  1777.           tf[ENEMY][newTF].yf:=stars[starnum].y;
  1778.         ELSE
  1779.           tf[ENEMY][newTF].dest:=0;
  1780.         END;
  1781.  
  1782.         fin:=FALSE;
  1783.         REPEAT
  1784.           SetCursorPos(1,18);
  1785.           PutStr("B?                            ");
  1786.           SetCursorPos(4,18);
  1787.           GetChar(ch);
  1788.           CASE ch OF
  1789.             |"M": PrintMap();
  1790.             |"H": Help(2);
  1791.             |"S": StarSummary();
  1792.             |"T": TFSummary();
  1793.             |"C": PrintColony();
  1794.             |"?":
  1795.             |"R": ResearchSummary();
  1796.             |"O": DisplayForces(ennum,plnum,enodds,plodds,battle);
  1797.             |"W": WithDraw(starnum,plnum);
  1798.                   DisplayForces(ennum,plnum,enodds,plodds,battle);
  1799.             |" ",
  1800.              "G": fin:=TRUE;
  1801.             |ELSE PutStr("!illegal command");
  1802.           END;
  1803.         UNTIL fin OR (NOT battle);
  1804.         ZeroTF(ENEMY,newTF);
  1805.         ZeroTF(player,plnum);
  1806.         IF tf[ENEMY][newTF].dest#0 THEN
  1807.           SetCursorPos(1,23);
  1808.           PutStr("en withdraws");
  1809.           SetCursorPos(14,23);
  1810.           DisplayTF(tf[ENEMY][newTF]);
  1811.           tf[ENEMY][ennum].t:=tf[ENEMY][ennum].t-tf[ENEMY][newTF].t;
  1812.           tf[ENEMY][ennum].s:=tf[ENEMY][ennum].s-tf[ENEMY][newTF].s;
  1813.           tf[ENEMY][ennum].c:=tf[ENEMY][ennum].c-tf[ENEMY][newTF].c;
  1814.           tf[ENEMY][ennum].b:=tf[ENEMY][ennum].b-tf[ENEMY][newTF].b;
  1815.           ZeroTF(ENEMY,ennum);
  1816.           DisplayForces(ennum,plnum,enodds,plodds,battle);
  1817.         END;
  1818.       END;
  1819.     END;
  1820.     ZeroTF(ENEMY,ennum);
  1821.     ZeroTF(player,plnum);
  1822.     Revolt(starnum);
  1823.     OnBoard(stars[starnum].x,stars[starnum].y);
  1824.   END TFBattle;
  1825.  
  1826.  
  1827.  
  1828. END Conquest2.
  1829.